<template>
    <view>
        <nav-bar :title="title"></nav-bar>
        <view class="padding-20" v-html="content"></view>
    </view>
</template>

<script setup lang="ts">
import { computed, ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import $apiCommon from '@/api/common';

let type: string;
const content = ref();
onLoad((option: any) => {
    type = option.type || 'privacy';
    getDetail();
});

const title = computed(() => {
    if (type === 'privacy') return '隐私政策';
    else if (type === 'Contract') return '用户协议';
    return '';
});

function getDetail() {
    $apiCommon.protocol(type).then((res: any) => {
        content.value = res.data.content;
    });
}
</script>
